<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    * {
        padding: 0;
        margin: 0;
    }

    .box {
        width: 500px;
        height: 300px;
        border: 1px solid;
        position: relative;
        margin: 20px auto;
    }

    #jiangxiang {
        position: absolute;
        top: 50%;
        left: 50%;
        font-size: 30px;
        color: red;
        transform: translate(-50%, -50%);
    }
   
    #canvas {
        position: absolute;
    }
</style>

<body>
    <div class="box">
        <p id="jiangxiang">
            
        </p>
        <canvas id="canvas" width="500" height="300"></canvas>
    </div>

</body>
<script>
    var jiang = document.getElementById('jiangxiang')
    var jiangxiang = ['50万', '100元', '1万元', '老徐买彩票必买不到', '50万']
    // var num = Math.floor( Math.random()*(最大值-最小值+1)+最小值 )
    var num = Math.floor(Math.random() * (jiangxiang.length-1 - 0 + 1) + 0)
    jiang.innerHTML= jiangxiang[num]
    var canvas=document.getElementById('canvas')
    var ctx = canvas.getContext('2d')
    ctx.fillStyle='#999d9c'
    ctx.fillRect(0,0,500,300)
    canvas.onmousedown=function(){
        canvas.onmousemove=function(e){
            console.log(e);
            ctx.clearRect(e.offsetX,e.offsetY,10,10)
        }
    }
    canvas.onmouseup=function(){
        canvas.onmousemove=null
    }
</script>

</html>